import {takeEvery, put} from 'redux-saga/effects'
import { search_products, search_products_success} from '../actions/search'
import axios from 'axios'
import {API} from '../../config'
function* handleSearch (action) {

    let response = yield axios.get(`${API}/products/search`,{params: action.payload})
    yield put(search_products_success({
        results: response.data
    }))
    
    
}

export default function* searchSaga () {
    yield takeEvery(search_products,handleSearch)
}